/*
 * delay.h
 *
 * Created: 2011-11-01 18:54:01
 *  Author: SZCZUR
 
 Require:
 
 #define F_CPU
 
 */ 

#ifndef DELAY_H_
#define DELAY_H_

#include <util/delay.h>

//not accurate!!!!!
void delay_us(uint16_t us) {
	const int max_us = 768 / (F_CPU / 1000000);
	while (us > max_us) {
		_delay_us(max_us);
		us -= max_us;
	}
	if (us > 0)
		_delay_loop_2(us * (F_CPU / 1000000) / 4);
}

//not accurate!!!!!
void delay_us_old(uint16_t us) {
	const int max_us = 768 / (F_CPU / 1000000);
	while (us > max_us) {
		_delay_us(max_us);
		us -= max_us;
	}
	while (us) {
		_delay_us(1);
		us--;
	}	
}

#endif /* DELAY_H_ */